Implementation of Dedicated Server in Isolation#498
Implementation of Dedicated Server in Isolation#498kuwacom wants to merge 50 commits intosmartcmd:mainfrom
Conversation
- Introduced `ServerMain.cpp` for the dedicated server logic, handling command-line arguments, server initialization, and network management. - Created `postbuild_server.ps1` script for post-build tasks, including copying necessary resources and DLLs for the dedicated server. - Added `CopyServerAssets.cmake` to manage the copying of server assets during the build process, ensuring required files are available for the dedicated server. - Defined project filters in `Minecraft.Server.vcxproj.filters` for better organization of server-related files.
- Introduced ServerLogger for logging startup steps and world I/O operations. - Implemented ServerProperties for loading and saving server configuration from `server.properties`. - Added WorldManager to handle world loading and creation based on server properties. - Updated ServerMain to integrate server properties loading and world management. - Enhanced project files to include new source and header files for the server components.
|
I hadn’t been merging upstream changes while implementing, so I’m in the middle of merging them now... |
# Conflicts: # Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpp # Minecraft.Client/Windows64/Network/WinsockNetLayer.cpp # Minecraft.Client/Windows64/Network/WinsockNetLayer.h
|
Some things have changed in the past day-ish, watch out for incompatibilities/redundant re-implementations of these:
|
|
So
|
Since 31881af56936aeef38ff322b975fd0 , `skinHud.swf` for 720 is not included in `MediaWindows64.arc`, the app crashes unless the virtual screen is set to HD.
|
It was partially affected by #495, but I was able to merge it without any issues. |
|
is it still only LAN multiplayer only? or can worlds be opened up to more people? |
|
It can be accessed from anywhere if you have a suitable network that can be accessed from the global internet (a network line that can open the specified TCP port). In short, it's a regular server app. |
|
oh damn. so i could run this on a vps? |
|
Yes, but since it still uses a lot of Windows API internally (to maintain compatibility), it requires a Windows system or a system that includes Windows API to run. I would like to eventually release a Linux version and put it into Docker. |
|
i mean, i've tried it on linux and it works fine. i could try and create a docker image if you'd like |
You can run it fine on Linux without a GUI launcher via umu |
seriously! |
|
wine also works really well. tried lutris and has similar results to umu |
|
Which one has a smaller image size? |
|
wine iirc |
|
Currently there are two approaches: the separated version (this pull request) and the The separated version modifies the world-saving logic and changes the startup logic, so integrating it into the client side would be a bit tricky. Alternatively, it would also be possible to keep both. |
|
Realistically speaking a completely separate Server executable should be our preferred way for this to work. The |
|
If we're planning to merge the separated server in the future, I was considering removing the |
Yeah |
|
Sorry, that’s not written in the description, but it’s still a dummy for now. |
Would it be possible to send the Dockerfile and docker-compose.yml? |
not using a docker image, which is surprising. i took your pr build and ran it on my vps. works REALLY well, minus the default server settings being awful (peaceful mode, no pvp etc) |
Changed it so that |
|
If this is functional even with a few caveats I think we'd be okay to merge it in. Would rather have this be something everyone can help you with easily on main than leave you dangling in this PR for longer than needed if that's something you'd prefer. Otherwise no rush, we can wait for you to be ready. |
|
When running this under Docker, how do I invoke commands to the server such as ban-ip? or is that impossible |
By default std in is disabled so you need to enable it. tty: true
stdin_open: trueWe'll commit these as defaults later. |
|
i got a question about the server console commands, you've created new commands and such but i can also see inside MinecraftServer.cpp alot of existing/old commands?, like time, these arent currently connected to the terminal? |
Even though the function is available, I cannot use it because I have not registered it. |
|
Is there any reason for CLI specific commands rather than a unified command implementation? Bukkit/Paper/JE uses the concept of a CommandSender which can be the console or a player, and iirc there’s some base code in the project that could be used to accomplish something like that. It’d be better for maintainability to only have one set of commands if we can help it |
|
To share my findings with server World size, NetworkGameInitData *param = new NetworkGameInitData();
if (config.hasSeed)
{
param->seed = config.seed;
}
+> //Set World Size For new Worlds
+> param->xzSize = 5*64; //(5*64);
+> param->hellScale = HELL_LEVEL_SCALE_LARGE;
param->saveData = worldBootstrap.saveData;
param->settings = app.GetGameHostOption(eGameHostOption_All);
param->dedicatedNoLocalHostPlayer = true;
LogStartupStep("starting hosted network game thread");
g_NetworkManager.HostGame(0, true, false, (unsigned char)config.maxPlayers, 0);
g_NetworkManager.FakeLocalPlayerJoined();We can also expand small worlds already generated by setting some app options, also inside app.SetGameHostOption(eGameHostOption_DoMobLoot, serverProperties.doMobLoot ? 1 : 0);
app.SetGameHostOption(eGameHostOption_DoTileDrops, serverProperties.doTileDrops ? 1 : 0);
app.SetGameHostOption(eGameHostOption_NaturalRegeneration, serverProperties.naturalRegeneration ? 1 : 0);
app.SetGameHostOption(eGameHostOption_DoDaylightCycle, serverProperties.doDaylightCycle ? 1 : 0);
+> //Upgrade World Size
+> app.SetGameNewWorldSize(64*5, true);
+> app.SetGameNewHellScale(HELL_LEVEL_SCALE_LARGE);
StorageManager.SetSaveDisabled(serverProperties.disableSaving);
// Read world name and fixed save-id from server.properties
// Delegate load-vs-create decision to WorldManagerCurrently worlds beyond 64*5 chunks wide cannot be created because of a hardcoded limit inside we just need to tie these values into a Dedicated Server Config file now so that we can easily define world sizes |
|
I’m back from my business trip, so I’ll resume working on this. |
Based on a quick investigation of the current implementation, it seems that while the original codebase has structures for invoking command functionality, it was not designed to be used directly from text input. Changing this would require significant modifications to both For now, the input handling, text dispatcher, and command suggestion logic are implemented on our side as a CLI-style interface. The actual command logic required for execution (such as Ideally, everything should be unified in the future (preferably sooner rather than later). |
|
Sounds good, that can be refactored in a follow up pr then |
- unify duplicated implementations that were copied repeatedly - update outdated patterns to more modern ones
`getHighestNonEmptyY()` returning `-1` occurs normally when the chunk is entirely air. The caller (`Minecraft.World/LevelChunk.cpp:2400`) normalizes `-1` to `0`.
|
The latest changes should now be integrated! |
Added the option. |
|
would it be possible to add a server.properties setting for the max amount of breeding animals? |
…builds to Actions
They are currently defined as constants internally, so there are no plans to make them configurable. |
|
@codeHusky
|
|
We’re definitely going to need a separate dedicated nightly server release so that’s perfect! :) |




Description
This PR introduces a Windows64 dedicated server executable (
Minecraft.Server) and expands the dedicated-server runtime/build pipeline.Compared to the initial pull request description, the following features have been newly added:
server.propertiessupport (including LAN advertise and host options),level-id,Minecraft.Clientchanges remain focused on dedicated-server bridge compatibility.#65
Changes
Dedicated Server Executable / Startup
Minecraft.Server/Windows64/ServerMain.cppMinecraft.Server/Minecraft.Server.vcxproj(+ filters)server.propertiesdefaults,level-id/level-name,-port,-ip/-bind,-name,-maxplayers,-seed,-loglevel,-helpserver.properties, it can also be integrated into fully autonomous deployment systems like Kubernetes.Dedicated Runtime Modules
ServerProperties(defaulting, normalization, persistence for dedicated options)WorldManager(load existing world bylevel-id, fallback by name, or create new world)ServerLogger(debug|info|warn|error)Minecraft.Server/Common/StringUtilsInteractive Server Console
ServerCli,ServerCliInput,ServerCliParser,ServerCliEngine,ServerCliRegistryhelp(?)stoplisttp(teleport)gamemode(gm)survival|creative|s|c|0|1).Minecraft.Client Bridge Changes (Dedicated Compatibility Scope)
Only dedicated-server compatibility behavior was changed in client networking paths:
Minecraft.Client/MinecraftServer.hNetworkGameInitData::dedicatedNoLocalHostPlayer.Minecraft.Client/Common/Network/GameNetworkManager.cppClientConnectioncreation.Minecraft.Client/Common/Network/PlatformNetworkManagerStub.cpplan-advertise).Minecraft.Client/Windows64/Network/WinsockNetLayer.h/.cppBuild / Tooling / Docs
CMakeLists.txt:MinecraftServertarget + post-build asset copycmake/CopyServerAssets.cmake: minimal dedicated runtime asset copyMinecraftConsoles.slnCOMPILE.md.gitignoredocker/dedicated-server/Dockerfiledocker/dedicated-server/entrypoint.shdocker-compose.dedicated-server.ymldocker-build-dedicated-server.shstart-dedicated-server.shREADME.mddedicated Docker section